/**
 * 用法见:
 *   test/src/types.test.js
 */
export default {
    isArray(obj) {
        return Array.isArray(obj);
    },

    isFunction(obj) {
        return Object.prototype.toString.call(obj) === '[object Function]';
    },

    /**
     * null | undefined ->  false
     * function -> true
     * @param obj
     * @return {boolean}
     */
    isObject(obj) {
        let type = typeof obj;
        return type === 'function' || type === 'object' && !!obj;
    },
    isArguments(obj) {
        return Object.prototype.toString.call(obj) === '[object Arguments]';
    },
    isString(obj) {
        return Object.prototype.toString.call(obj) === '[object String]';
    },

    /**
     * NaN ->  true
     * Infinity -> true
     *
     * @param obj
     * @return {boolean}
     */
    isNumber(obj) {
        return Object.prototype.toString.call(obj) === '[object Number]';
    },

    isDate(obj) {
        return Object.prototype.toString.call(obj) === '[object Date]';
    },
    isRegExp(obj) {
        return Object.prototype.toString.call(obj) === '[object RegExp]';
    },
    isError(obj) {
        return Object.prototype.toString.call(obj) === '[object Error]';
    },
    isSymbol(obj) {
        return Object.prototype.toString.call(obj) === '[object Symbol]';
    },
    isMap(obj) {
        return Object.prototype.toString.call(obj) === '[object Map]';
    },
    isWeakMap(obj) {
        return Object.prototype.toString.call(obj) === '[object WeakMap]';
    },
    isSet(obj) {
        return Object.prototype.toString.call(obj) === '[object Set]';
    },
    isWeakSet(obj) {
        return Object.prototype.toString.call(obj) === '[object WeakSet]';
    },
};

